home *** CD-ROM | disk | FTP | other *** search
- Path: hops.cs.jhu.edu!lasher
- From: lasher@hops.cs.jhu.edu (John E. Davis)
- Newsgroups: comp.lang.c
- Subject: Re: String Problem
- Date: 26 Mar 1996 05:54:43 GMT
- Organization: JHU computer science
- Message-ID: <4j80r4$9ir@blaze.cs.jhu.edu>
- References: <4j6l61$4no@B1FF.mindspring.com>
- NNTP-Posting-Host: hops.cs.jhu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Shon Frazier (vtipres@atl.mindspring.com) expostulated:
- > This is supposed to be a variation on sample code from a textbook.
- > Can anyone tell me why NameCheck = 0 when I run the program?
-
- > /*
- > Testing character transactions.
- > */
-
- > #include <stdio.h>
- > #include <ctype.h>
-
- > int main()
- > {
- > char Name[11] = "John";
- > char *WhereName;
- > int NameCheck = 0;
-
- > WhereName = Name;
-
- > if ( WhereName == "John" )
-
- try using if(!(strcmp(WhereName, "John"))) instead. remember that strcmp
- returns 0 if the strings are the same so you need the ! in front.
-
-
- john davis
- lasher@hops.cs.jhu.edu
-